TARGET = reacTIVision
CSOURCES = $(shell ls ../ext/libfidtrack/*.c ../common/*.c)  
COBJECTS = $(CSOURCES:.c=.o)
PMSOURCES = $(shell ls ../ext/portmidi/pm_common/*.c ../ext/portmidi/pm_linux/*.c ../ext/portmidi/porttime/porttime.c ../ext/portmidi/porttime/ptlinux.c)
PMOBJECTS = $(PMSOURCES:.c=.o)
CPPSOURCES = $(shell ls ./*.cpp ../common/*.cpp  ../ext/libfidtrack/*.cpp ../ext/libdtouch/*.cpp ../ext/tinyxml/*.cpp) 
CPPOBJECTS = $(CPPSOURCES:.cpp=.o)
OSCSOURCES = $(shell ls ../ext/oscpack/ip/posix/*.cpp ../ext/oscpack/osc/*.cpp) 
OSCOBJECTS = $(OSCSOURCES:.cpp=.o)

SDL_CFLAGS  := $(shell sdl-config --cflags)
SDL_LDFLAGS := $(shell sdl-config --libs)

INCLUDES = -I../ext/oscpack -I../ext/libfidtrack -I../ext/libdtouch -I../ext/ccvt -I../common -I../ext/portmidi/pm_common -I../ext/portmidi/porttime -I../ext/tinyxml
COPTS  = -Wall -O3 -finline-functions -ffast-math -funroll-all-loops -fomit-frame-pointer
CDEBUG = -Wall -g
CFLAGS = $(COPTS) $(SDL_CFLAGS) $(INCLUDES) -DLINUX -DOSC_HOST_LITTLE_ENDIAN -DNDEBUG -DPMALSA
#CFLAGS = $(CDEBUG) $(SDL_CFLAGS) $(INCLUDES) -DLINUX -DOSC_HOST_LITTLE_ENDIAN -DNDEBUG -DPMALSA
CXXFLAGS = $(CFLAGS)

LIBS = $(SDL_LDFLAGS) -lraw1394 -ldc1394_control -lasound ../ext/ccvt/libccvt.a

all:	$(TARGET) 

$(TARGET) : $(CPPOBJECTS) $(COBJECTS) $(OSCOBJECTS) $(PMOBJECTS)
	$(CXX) -o $@ $+ $(LIBS) 
	#strip $(TARGET)

clean:
	rm -f $(TARGET) $(CPPOBJECTS) $(COBJECTS) $(OSCOBJECTS) $(PMOBJECTS)

run:	$(TARGET)
	./$(TARGET)

install: $(TARGET)
	install -d $(DESTDIR)$(BINDIR)
	install -d $(DESTDIR)$(PREFIX)/share/$(TARGET)
	install -m 755 -c $(TARGET) $(DESTDIR)$(BINDIR)
	install -m 644 -c ../README.txt $(DESTDIR)$(PREFIX)/share/$(TARGET)
	install -m 644 -c ../LICENSE.txt $(DESTDIR)$(PREFIX)/share/$(TARGET)
	install -m 644 -c ../CHANGELOG.txt $(DESTDIR)$(PREFIX)/share/$(TARGET)
	install -m 644 -c ../GPL.txt $(DESTDIR)$(PREFIX)/share/$(TARGET)
	install -m 644 -c ../symbols/default.pdf $(DESTDIR)$(PREFIX)/share/$(TARGET)/default.pdf
	install -m 644 -c ../symbols/finger.pdf $(DESTDIR)$(PREFIX)/share/$(TARGET)/finger.pdf
	install -d $(DESTDIR)$(PREFIX)/share/$(TARGET)/classic
	install -m 644 -c ../symbols/classic/*.png $(DESTDIR)$(PREFIX)/share/$(TARGET)/classic
	install -d $(DESTDIR)$(PREFIX)/share/$(TARGET)/dtouch
	install -m 644 -c ../symbols/dtouch/*.png $(DESTDIR)$(PREFIX)/share/$(TARGET)/dtouch
	install -d $(DESTDIR)$(PREFIX)/share/$(TARGET)/calibration
	install -m 644 -c ../calibration/*.pdf $(DESTDIR)$(PREFIX)/share/$(TARGET)/calibration
	install -d $(DESTDIR)$(PREFIX)/share/$(TARGET)/midi
	install -m 644 -c ../midi/* $(DESTDIR)$(PREFIX)/share/$(TARGET)/midi

